﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SocketClient
{
    public partial class SocketClientApp : Form
    {
        public SocketClientApp()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 连接
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_connect_Click(object sender, EventArgs e)
        {
            var socketCient = SpectrumClient.SocketCient.Instance;
            socketCient.MsgCallback = (msg) =>
            {
                Invoke(new Action(() =>
                {
                    tbx_msg.AppendText(msg + Environment.NewLine);
                }));
            };
            btn_connect.Enabled = false;
        }

        /// <summary>
        /// 发送消息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_send_Click(object sender, EventArgs e)
        {
            var data = tbx_data.Text.Trim();
            SpectrumClient.SocketCient.Instance.SendLoop("测试事件", data);
        }
    }
}